package com.hzx.demo.activity;

import android.os.Handler;
import android.support.v7.app.AppCompatActivity;

import com.hzx.demo.R;
import com.hzx.demo.util.Entry;
import com.hzx.demo.view.VisualizerView;

import org.androidannotations.annotations.AfterViews;
import org.androidannotations.annotations.EActivity;
import org.androidannotations.annotations.ViewById;

import java.util.Random;

/**
 * Created by ldkxingzhe on 2016/6/30.
 */
@EActivity(R.layout.activity_visualizer)
@Entry(desc = "示波器", createTime = "2016-06-30")
public class VisualizerViewActivity extends AppCompatActivity{
    @SuppressWarnings("unused")
    private static final String TAG = "VisualizerViewActivity";

    @ViewById(R.id.visualizer_view)
    VisualizerView mVisualizerView;
    Handler mHandler;

    @AfterViews
    protected void afterView(){
        mHandler = new Handler();
        mHandler.postDelayed(mRunnable, 300);
    }

    private Runnable mRunnable = new Runnable() {
        @Override
        public void run() {
            int one = new Random().nextInt(600);
            mVisualizerView.updateAmplitude(one / 600f);
            mHandler.postDelayed(mRunnable, 200);
        }
    };
}
